package com.web.dao;

import com.web.entity.UserMargin;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

public interface UserMarginMapper {
    @Delete({
        "delete from APP_USER_MARGIN",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer id);

    @Insert({
        "insert into APP_USER_MARGIN (conversion, invite_code_length, ",
        "level, create_time, ",
        "modify_time, is_review, ",
        "create_by, modify_by, ",
        "customer_service_mobile, contact_cost)",
        "values (#{conversion,jdbcType=DOUBLE}, #{inviteCodeLength,jdbcType=INTEGER}, ",
        "#{level,jdbcType=INTEGER}, #{createTime,jdbcType=TIMESTAMP}, ",
        "#{modifyTime,jdbcType=TIMESTAMP}, #{isReview,jdbcType=INTEGER}, ",
        "#{createBy,jdbcType=VARCHAR}, #{modifyBy,jdbcType=VARCHAR}, ",
        "#{customerServiceMobile,jdbcType=VARCHAR}, #{contactCost,jdbcType=DECIMAL})"
    })
    @SelectKey(statement="SELECT LAST_INSERT_ID()", keyProperty="id", before=false, resultType=Integer.class)
    int insert(UserMargin record);

    int insertSelective(UserMargin record);

    @Select({
        "select",
        "id, conversion, invite_code_length, level, create_time, modify_time, is_review, ",
        "create_by, modify_by, customer_service_mobile, contact_cost",
        "from APP_USER_MARGIN",
        "where id = #{id,jdbcType=INTEGER}"
    })
    @ResultMap("BaseResultMap")
    UserMargin selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(UserMargin record);

    @Update({
        "update APP_USER_MARGIN",
        "set conversion = #{conversion,jdbcType=DOUBLE},",
          "invite_code_length = #{inviteCodeLength,jdbcType=INTEGER},",
          "level = #{level,jdbcType=INTEGER},",
          "create_time = #{createTime,jdbcType=TIMESTAMP},",
          "modify_time = #{modifyTime,jdbcType=TIMESTAMP},",
          "is_review = #{isReview,jdbcType=INTEGER},",
          "create_by = #{createBy,jdbcType=VARCHAR},",
          "modify_by = #{modifyBy,jdbcType=VARCHAR},",
          "customer_service_mobile = #{customerServiceMobile,jdbcType=VARCHAR},",
          "contact_cost = #{contactCost,jdbcType=DECIMAL}",
        "where id = #{id,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(UserMargin record);

    UserMargin getMarginInfo();
}